#!/bin/bash

# Copyright (c) 2021-2023 Forlinx Open Source Organization .
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

ROOT_DIR=../../../../../
echo "############begin##############"

BASE_STARTUP_INIT=${ROOT_DIR}/base/startup/init/
BASE_SECURITY=${ROOT_DIR}/base/security/selinux_adapter/sepolicy
BASE_UPDATE=${ROOT_DIR}/base/update/updater
BASE_HIVIEWDFX=${ROOT_DIR}/base/hiviewdfx
DRIVER_AUDIO=${ROOT_DIR}/drivers/hdf_core/framework/model/audio/
KERNEL_COMMOM_MODULES=${ROOT_DIR}/kernel/linux/common_modules
DRIVER_I2C_INC=${ROOT_DIR}/drivers/hdf_core/framework/support/platform/include/i2c
DRIVER_AUDIO_CFG=${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/audio
DRIVER_USB_CFG=${ROOT_DIR}/drivers/hdf_core/adapter/khdf/linux/model/usb/
BUILD_PATH=${ROOT_DIR}/build/

INPUT_PATH=${ROOT_DIR}/drivers/hdf_core/framework/model/input/driver
Boot_Animation_PATH=${ROOT_DIR}/foundation/graphic/graphic_2d/frameworks/bootanimation/data/
powermgr_PATH=${ROOT_DIR}/base/powermgr/power_manager/services/native/profile/
powerstate_PATH=${ROOT_DIR}/base/powermgr/power_manager/services/native/src/
FOUNDATION_GRAPHIC_PATH=${ROOT_DIR}/foundation/graphic/graphic_2d
FOUNDATION_MULTIMEDIA_PATH=${ROOT_DIR}/foundation/multimedia
FOUNDATION_FILEMANAGEMENT_PATH=${ROOT_DIR}/foundation/filemanagement
THIRD_PARTY_FFMPEG_PATH=${ROOT_DIR}/third_party/ffmpeg
FOUNDATION_COMMUNICATION_PATH=${ROOT_DIR}/foundation/communication
UITEST_PATH=${ROOT_DIR}/test/testfwk/arkxtest/uitest/test

echo "############build##############"
cp -arf ./build/* ${BUILD_PATH}/
cp -arf ./model/input/*  ${INPUT_PATH}/
echo "############BootAnimation##############"
cp -arf ./BootAnimation/bootvideo.mp4 ${Boot_Animation_PATH}/bootvideo.mp4
echo "############power##############"
cp -arf ./powermgr/power_mode_config.xml ${powermgr_PATH}/power_mode_config.xml
cp -arf ./powermgr/power_state_machine.cpp ${powerstate_PATH}/power_state_machine.cpp


echo "############base startup##############"
cp -arf ./base/startup/init/* ${BASE_STARTUP_INIT}/
cp -arf ./base/security/selinux_adapter/sepolicy/* ${BASE_SECURITY}/
cp -arf ./base/update/updater/* ${BASE_UPDATE}/
cp -arf ./base/powermgr/battery_manager/charger/src/fbdev_driver.cpp ${ROOT_DIR}/base/powermgr/battery_manager/charger/src/fbdev_driver.cpp
cp -arf ./base/hiviewdfx/* ${BASE_HIVIEWDFX}/

echo "############drivers startup##############"
cp  -arf ./drivers/hdf_core/framework/model/audio/* ${DRIVER_AUDIO}/
cp  -arf ./drivers/hdf_core/adapter/khdf/linux/model/usb/* ${DRIVER_USB_CFG}/
cp  -arf ./drivers/hdf_core/adapter/khdf/linux/model/audio/* ${DRIVER_AUDIO_CFG}/
cp  -arf ./drivers/hdf_core/framework/support/platform/include/i2c/* ${DRIVER_I2C_INC}/

echo "###########foundation###############"
cp  -arf ./foundation/graphic/graphic_2d/*  ${FOUNDATION_GRAPHIC_PATH}/
cp  -arf ./foundation/multimedia/* ${FOUNDATION_MULTIMEDIA_PATH}/
cp  -arf ./foundation/filemanagement/* ${FOUNDATION_FILEMANAGEMENT_PATH}/
cp  -arf ./foundation/communication/* ${FOUNDATION_COMMUNICATION_PATH}/

echo "###########uitest###############"
#cp -arf ./uitest/core/* ${UITEST_PATH}/

echo "###########common_modules###############"
cp -arf ./kernel/linux/common_modules/* ${KERNEL_COMMOM_MODULES}/
echo "###########third_party###############"
cp  -arf ./third_party/ffmpeg/* ${THIRD_PARTY_FFMPEG_PATH}/
echo "############success##############"


#xts build
#XTS_PATCH_DIR=../../../
#XTS_BUTTON12_PATCH=${XTS_PATCH_DIR}/device/board/forlinx/okt527/patch/xts/14156.diff
#XTS_ACEETSLAYOUTLIST_PATCH=${XTS_PATCH_DIR}/device/board/forlinx/okt527/patch/xts/14225.diff

#cd ${ROOT_DIR}/test/xts/acts/
#patch -p1  < ${XTS_BUTTON12_PATCH}
#patch -p1  < ${XTS_ACEETSLAYOUTLIST_PATCH}

